package com.eling.elcms.cater.model;

import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.ordermanager.model.ServicePoint;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;

import javax.persistence.*;

/**
 * 菜品类型
 *
 */
@Entity
@Table(name = "cate_dishtype",
		uniqueConstraints = {@UniqueConstraint(columnNames={"name","pkServicePoint"})})
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class, parameter = "iOrder"),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "servicepoint:servicePoint")})
public class DishType extends BaseModel {
	private static final long serialVersionUID = -5783376013422275951L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkDishType;
	
	/** 类型名称 **/
	@Column
	@Field
	private String name;
	
	/** 序号 */
	@Column
	@Field
	private Integer iOrder;
	
	/** 备注 */
	@Column
	@Field
	private String remark;
	
	/** 服务点 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkServicePoint")
	private ServicePoint servicePoint;
	
	@Version
	private Integer version;

	public Long getPkDishType() {
		return pkDishType;
	}

	public void setPkDishType(Long pkDishType) {
		this.pkDishType = pkDishType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getiOrder() {
		return iOrder;
	}

	public void setiOrder(Integer iOrder) {
		this.iOrder = iOrder;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public ServicePoint getServicePoint() {
		return servicePoint;
	}

	public void setServicePoint(ServicePoint servicePoint) {
		this.servicePoint = servicePoint;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
}
